package com.lujianfei.imagesearch.presenter;

import com.lujianfei.imagesearch.contract.MnistLabelContract;
import com.lujianfei.imagesearch.utils.MnistReader;
import com.lujianfei.imagesearch.utils.MnistReader.MnistInfo;

public class MnistLabelPresenter extends MnistLabelContract.Presenter {

	private MnistReader mnistReader = new MnistReader();
	
	public MnistLabelPresenter(MnistLabelContract.View mView) {
		super(mView);
	}


	@Override
	public void openLabel(String fileName,MnistInfo info) {
		StringBuilder sb = new StringBuilder();
		int[] labels = mnistReader.getLabels(fileName,info);
		if(!info.success) {
			return;
		}
		for (int i = 0; i < labels.length; i++) {
			sb.append(labels[i]).append("\r\n");
		}
		mView.setLabels(sb.toString());
	}
	
	void log(String text) {
		System.out.println("MainPresenter:" + text);
	}
}
